<template>
<view class="flx_cenetr_content_container">
     
    <block v-if="!List">
      <view class="none">
        <image mode="widthFix" src="https://image1.sansancloud.com/xianhua/2019_12/17/11/9/46_337.jpg?x-oss-process=style/preview_120"></image>
        <text>什么都没有</text>
      </view>
    </block>

    <view v-else class="flx_user_container">
      <view class="countUser">
        <view>共{{count}}人</view>
      </view>
      <view class="flx_user_item" v-for="(item, index) in List" :key="index">
        <image :src="(item.headimgurl ? item.headimgurl : '/images/icons/me1.png')"></image>
        <view class="flx_user_item_info">
          <text>{{item.nickname ? item.nickname : "无昵称"}}</text>
          <view>直接推广人数: {{item.levelOneFxUserCount}}</view>
          <view class="time">{{item.addTime}}</view>
        </view>
      </view>
    </view>
    


</view>
</template>

<script>

export default {
  data() {
    return {
      List: [],
      count: 0,

      /**
       * 生命周期函数--监听页面加载
       */
      options: {},
      listPage: {
        page: 1,
        pageSize: 0,
        totalSize: 0,
        curpage: 1
      }
    };
  },

  components: {},
  props: {},
  onLoad: function (options) {
    this.options = options;
    this.get_fx_usersFun(options);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.favouriteList = [];
    this.listPage.page = 1;
    this.get_fx_usersFun(this.options, 1);
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this;

    if (that.listPage.totalSize > that.listPage.curPage * that.listPage.pageSize) {
      that.listPage.page++;
      this.get_fx_usersFun(this.options);
    }
  },
  methods: {
    get_fx_usersFun: function (options, fresh) {
      let getParam = {};
      getParam.page = this.listPage.page;
      var customIndex = getApp().globalData.AddClientUrl("/get_mendian_platform_users_admin_mendian_json.html", getParam, 'post');
      var that = this;
      getApp().globalData.showToastLoading('loading', true);
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.headerPost,
        method: 'POST',
        success: function (res) {
          wx.hideLoading();
          console.log(res.data);

          if (res.data.errcode == 0) {
            that.listPage.pageSize = res.data.relateObj.pageSize;
            that.listPage.curPage = res.data.relateObj.curPage;
            that.listPage.totalSize = res.data.relateObj.totalSize;
            that.setData({
              count: res.data.relateObj.totalSize
            });
            let result = res.data.relateObj.result;
            let List = that.List;

            if (fresh) {
              List = [];
            }

            if (!result || result.length == 0) {
              that.setData({
                List: null
              });
            } else {
              List = List.concat(result);
              that.setData({
                List: List
              });
            }
          }
        },
        fail: function (res) {
          wx.hideLoading();
          getApp().globalData.loadFail();
        }
      });
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
@import "./index.css";
</style>